<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>窗口加载事件</title>
    <script type="text/javascript">
        /*
        setTimeout(function(){
            var oDiv = document.getElementById('box');
            console.log(oDiv);
            oDiv.onclick = function(){
                this.innerHTML = 'test05';
        }
        }, 10)
        */

        // 等待文档元素加载完成才会调用onload()
        window.onload = function(){
            var oDiv = document.getElementById('box');
            console.log(oDiv);
            oDiv.onclick = function(){
                this.innerHTML = 'test06';
            }
        }

        // 容易覆盖上一个事件
        // window.onload = function(){
            // console.log(11111);
        // }
    </script>
</head>
<body>
    <div id="box">test03</div>
</body>
</html>